package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.mapper.ReportAgeMapper;
import com.itheima.service.ReportAgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description:
 * @Version: V1.0
 */
@Service(interfaceClass = ReportAgeService.class)
@Transactional
public class ReportAgeServiceImpl implements ReportAgeService {
    @Autowired
    private ReportAgeMapper reportAgeMapper;

    @Override
    public List<Integer> findNumbersByDateList(List<String> list) {
        List<Integer> numbers =new ArrayList<>();
        for (int i = 0; i < list.size()-1; i++) {
            String endDate = list.get(i);
            String startDate = list.get(i + 1);
            numbers.add(reportAgeMapper.findNumberByDateList(startDate,endDate));
        }
        return numbers;
    }
}
